<template>
  <div>
    <el-card class="ep-card ep-search">
      <el-row :gutter="0">
        <el-col :span="3" style="float:right">
          <el-button type="primary"  @click="back">返回</el-button>
        </el-col>
        <el-col :span="2" style="float:right">
          <el-button type="success"  @click="submit">提交</el-button>
        </el-col>
        <el-col :span="2" style="float:right">
          <el-button type="success"  @click="save">保存</el-button>
        </el-col>
      </el-row>
    </el-card>
    <el-tabs type="border-card" @tab-click="changeTab" v-model="activeName">
      <el-tab-pane label="项目信息" name="tab1">
        <projHandleDisplay ref='projHandleDisplay'></projHandleDisplay>
      </el-tab-pane>
      <el-tab-pane label="用款信息" name="tab2">
        <money ref='money'></money>
      </el-tab-pane>
      <el-tab-pane label="审批意见" name="tab3">
        <options ref='options'></options>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
      
<script>
export default {
  components: {
      projHandleDisplay: require("@/pages/biz/proj/projDisplay/projHandleDisplay.vue").default,
      options: require("@/pages/biz/after/component/options.vue").default,
      money: require("@/pages/biz/after/component/money.vue").default,
  },
  data() {
    return {
      // 当前显示的tab页面
      activeName: 'tab1',
    };
  },
  computed: {},
  mounted() {
      // this.init();
  },
  methods: {
    /**
     * tab标签切换
     */
    changeTab() {

    },
    /**
     * 返回
     */
    back(){
      this.$router.push({path:"/proj/projHandleList"});
    },
    init() {
      //合作银行列表
      this.$refs.entBaseComponentDisplay.init(this.entId);
    },
    save(){
      let projHandle= this.$refs.projHandleComponent.getdata();
      let user=JSON.parse(sessionStorage.getItem("user"));
      projHandle.createUserId=user.id;
      projHandle.createUserName=user.realName;
      projHandle.projApplyId=this.projApplyId;
      this.$api.formPost( 'biz/project/doAcceptance',projHandle).then(res => {
        if(res.retHead.code=="0000000"){
              this.projId=res.retBody;
              if (this.projId) {
                this.isProjMate = false;
              }
              this.$message({
                  type: 'success',
                  message: "保存成功！"
              });
          }else{
            
              this.$message({
                  type: 'error',
                  message: res.retHead.message
              });
          }
      });
    },
    submit(){
      let projHandle= this.$refs.projHandleComponent.getdata();
      let user=JSON.parse(sessionStorage.getItem("user"));
      projHandle.createUserId=user.id;
      projHandle.createUserName=user.realName;
      projHandle.workflowCode="005";
      projHandle.projApplyId=this.projApplyId;
      if(!this.projId){
        this.$message({
                      type: 'error',
                      message: "请先保存，再提交",
            });
            return;
      }
      projHandle.id=this.projId;
      this.$api.formPost( 'biz/project/doStart',projHandle).then(res => {
        console.log(res);
            if(res.retHead.code=="0000000"){
                  this.$message({
                      type: 'success',
                      message: "流程启动成功！"
                  });
              }else{
                
                  this.$message({
                      type: 'error',
                      message: res.retHead.message
                  });
              }
          });
    },
    /**
     * 保存
     */
    changeTab(a, b) {
      let tabName = b.target.innerText;
      if ('材料收集' == tabName) {
        this.$refs.projMateComponent.doSaveMateList(this.projId, '1');
      }
    },
  },
  created() {}
};
</script>
<style lang='scss' scoped>
</style>